<?php
namespace app\api\service;
use think\Controller;
use think\Loader;

class QrCode extends Controller {

    // 生成二维码接口
    static public function creation_qr_code($param) {
        if( !isset($param['type']) ||  !isset($param['obj_id'])) return ['data'=>'','code'=>400001,'msg'=> 'FAULT'];
        try{
            Loader::import('QRcode.phpqrcode');
            $qr_code_image = 'chuku' . DS . time() . '_type_' . $param['type'] . '_obj_id_' . $param['obj_id'] . '.png';  // 出库二维码地址
            $qr_code_url = ROOT_PATH . 'public' . DS . 'qr_code' . DS .$qr_code_image;
            \QRcode::png('type=' . $param['type'] . '&obj_id=' . $param['obj_id'], $qr_code_url, '', 6, 2); //生成二维码
            erweima_add_log($qr_code_url); //添加logo

            return ['data'=>['qr_code_img' => $qr_code_image],'code'=>200,'msg'=> 'SUCCESS'];
        } catch (\Exception $e) {
            return ['data'=>'','code'=>0,'msg'=> $e->getMessage()];
        }
    }

}





